/*
 * Copyright 2003-2007 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

package com.colony.networkvm;

import com.argot.ResourceDictionaryLoader;
import com.argot.TypeException;
import com.argot.TypeLibrary;
import com.argot.TypeReaderAuto;
import com.argot.auto.TypeArrayMarshaller;
import com.argot.meta.MetaMarshaller;
import com.argot.remote.MetaInterface;
import com.colony.networkvm.instruction.NvmInstruction;
import com.colony.networkvm.instruction.NvmLoadCRLObject;
import com.colony.networkvm.instruction.NvmLoadHeapObject;
import com.colony.networkvm.instruction.NvmReturn;
import com.colony.networkvm.instruction.NvmStoreHeapObject;
import com.colony.networkvm.instruction.NvmToHostInstruction;
import com.colony.networkvm.machine.NvmHeap;
import com.colony.networkvm.machine.NvmState;
import com.colony.networkvm.proxy.NvmMetaMethodCall;

public final class NvmLoader
extends ResourceDictionaryLoader
{
	public static final String DICTIONARY = "networkvm.dictionary";
	
	public NvmLoader()
	{
		super( DICTIONARY );
	}
	
	public String getName()
	{
		return DICTIONARY;
	}
	
	public void bind( TypeLibrary library )
	throws TypeException
	{
		library.bind( "nvm.state", new TypeReaderAuto( NvmState.class ), new NvmState.NvmStateLibraryWriter(), NvmState.class );
		library.bind( "nvm.instructions", new TypeArrayMarshaller(), new TypeArrayMarshaller(), NvmInstruction[].class );
		library.bind( "nvm.instruction", new MetaMarshaller(), new MetaMarshaller(), null);
		library.bind( "nvm.instruction.to_host",  new NvmToHostInstruction.NvmToHostInstructionTypeReader(),new NvmToHostInstruction.NvmToHostInstructionTypeWriter(), NvmToHostInstruction.class );
		library.bind( "nvm.instruction.load_crl_object", new NvmLoadCRLObject.NvmLoadCRLObjectTypeReader(), new NvmLoadCRLObject.NvmLoadCRLObjectTypeWriter(), NvmLoadCRLObject.class );
		library.bind( "nvm.instruction.load_heap_object", new TypeReaderAuto(NvmLoadHeapObject.class), new NvmLoadHeapObject.NvmLoadHeapObjectTypeLibraryWriter(), NvmLoadHeapObject.class );
		library.bind( "nvm.instruction.named_method_call", new NvmMetaMethodCall.NvmMetaMethodCallTypeReader(), new NvmMetaMethodCall.NvmMetaMethodCallTypeWriter(), NvmMetaMethodCall.class );
		library.bind( "nvm.instruction.return" , new NvmReturn.NvmReturnTypeReader(), new NvmReturn.NvmReturnTypeWriter(), NvmReturn.class );
		library.bind( "nvm.instruction.store_heap_object", new TypeReaderAuto(NvmStoreHeapObject.class), new NvmStoreHeapObject.NvmStoreHeapObjectTypeLibraryWriter(), NvmStoreHeapObject.class );
		library.bind( "nvm.heap", new NvmHeap.NvmHeapTypeLibraryReader(), new NvmHeap.NvmHeapTypeLibraryWriter(), NvmHeap.class );
		library.bind( "nvm.host", new MetaInterface.MetaInterfaceReader(), new MetaInterface.MetaInterfaceWriter(),INvmHost.class );
		
	}

}
